---
id: 65c644829cfb63acf3479d09
title: Step 28
challengeType: 20
dashedName: step-28
---

# --description--

Insert the nodes in the list `nodes` into the `bst` instance by iterating over the list and calling the `insert` method on each node in the list. Use `node` as the iteration variable.

# --hints--

You should have a `for node in nodes` loop.

```js
assert.match(code, /for\s+node\s+in\s+nodes/);
```

You should have `bst.insert(node)` inside the `for` loop.

```js
assert.match(code, /bst\.insert/);
```

# --seed--

## --seed-contents--

```py

class TreeNode:

    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None


class BinarySearchTree:

    def __init__(self):
        self.root = None

    def _insert(self, node, key):
        if node is None:
            return TreeNode(key)

        if key < node.key:
            node.left = self._insert(node.left, key)
        elif key > node.key:

            node.right = self._insert(node.right, key)
        return node

    def insert(self, key):
        self.root = self._insert(self.root, key)
        
    def _search(self, node, key):
        if node is None or node.key == key:
            return node
        if key < node.key:
            return self._search(node.left, key)
        return self._search(node.right, key)
    
    def search(self, key):
        return self._search(self.root, key)

--fcc-editable-region--
bst = BinarySearchTree()

nodes = [50, 30, 20, 40, 70, 60, 80]

--fcc-editable-region--
```
